<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript">
    $(document).ready(function() {

        $('#tree').treegrid({
            title:$('#titleName').val(),
            nowrap: false,
            rownumbers: true,
            animate:true,
            collapsible:true,
            idField:'ref',
            treeField:'ref',
            frozenColumns:[
                [
                    {title:$('#refNo').val(),field:'ref',width:200,
                        formatter:function(value) {
                            return '<span style="color:red">' + value + '</span>';
                        }
                    }
                ]
            ],
            columns:[
                [
                    {field:'name',title:$('#name').val(),width:250},
                    {field:'planNo',title:$('#plane').val(),width:100},
                    {field:'lot',title:$('#lot').val(),width:100},
                    {field:'details',title:$('#detail').val(),width:50}
                ]
            ]
        });

        <s:iterator status="lands" value="landList">
        <s:if test="#session.userGroup =='slc'">
        var data = [
            {
                ref: '<s:property value="id"/>',
                name: '<s:property value="nameOfTheLand"/>',
                planNo: '<s:property value="planNumber"/>',
                lot: '<s:property value="lotNumber"/>',
                /*details: '<a title="View Land Details" href="printDetailLandInformationByApplicant.do?landId=<s:property value="id"/>">View</a>'*/
                details: '<a title="View Land Details" href="viewDetailLandReportByApplicant.do?landId=<s:property value="id"/>">View</a>'
            }
        ];

        </s:if>
        <s:else>
        var data = [
            {
                ref: '<s:property value="id"/>',
                name: '<s:property value="nameOfTheLand"/>',
                planNo: '<s:property value="planNumber"/>',
                lot: '<s:property value="parentLand.lotNumber"/>',
                /*details: '<a title="View Land Details" href="printDetailLandInformationToLandAttach.do?landId=<s:property value="id"/>">View</a>'*/
                details: '<a title="View Land Details" href="viewDetailLandReportByAttachLand.do?landId=<s:property value="id"/>">View</a>'
            }
        ];

        </s:else>


        $('#tree').treegrid('append', {
            parent:'<s:property value="parentLand.id"/>',
            data: data
        });
        </s:iterator>
    });
</script>
<s:if test="landList.size > 0">
    <table id="tree" class="width-100">
    </table>
    </br>
</s:if>

<s:hidden id="titleName" value="%{getText('detailed_land_info.label')}"/>
<s:hidden id="refNo" value="%{getText('slmsSerialNumber.label')}"/>
<s:hidden id="name" value="%{getText('name_of_the_land.label')}"/>
<s:hidden id="plane" value="%{getText('plan_no.label')}"/>
<s:hidden id="lot" value="%{getText('lot_no.label')}"/>
<s:hidden id="detail" value="%{getText('detail.label')}"/>
<s:hidden id="view" value="%{getText('view.label')}"/>
